var express = require("express");
var router = express.Router();
var data = require("./data");

// http://118.24.239.63:3000/api/rated/list

const scSort = data
  .sort((a, b) => {
    return b.sc - a.sc;
  })
  .slice(0, 6);

const wishSort = data
  .filter((item) => item.sc === 0)
  .sort((a, b) => {
    return b.wish - a.wish;
  })
  .slice(0, 6);

/* GET users listing. */
router.get("/list", function (req, res, next) {
  res.json({
    success: true,
    data: [...scSort, ...wishSort],
  });
});

module.exports = router;
